<template>
  <u-form-grid :data="formGrid"></u-form-grid>
</template>

<script>
  import values from '../../utils/values'

  export default {
    name: 'Customers',
    data() {
      return {
        formGrid: {
          options: {
            version: 'v2',
            url: {
              page: "/customers/receivers/page",
              save: "/customers/receivers/save",//记录添加和修改提交的地址，如果提交的对象有id则为修改
              delete: "/customers/receivers/delete",//记录删除的提交地址，通过提交id的集合来实现一个或者多个记录
              get: "/customers/receivers/find",//查看和编辑时用于查询对象的接口，参数为定义的keys
            }
          },
          tips: {"title": "地址管理", "content": "FormGrid是一个结合表单查询、修改、删除等全功能的组件。方便快速实现CRUD功能!"},

          form: {
            modal: {
              title: "地址信息"
            },
            columns: [
              {label: "收件人名", type: "text", name: "consignee", required: false},
              {label: "手机号", type: "text", name: "mobile", required: false},
              {label: "邮编", type: "text", name: "zipCode", required: false},
              {label: "所属区域", type: "text", name: "areaId", required: false,},
              {label: "地址", type: "text", name: "address", required: false},
              {label: "是否默认", type: "select", name: "defaultReceiver", required: false, data: values.bool},
            ]
          },
          toolbar:{
            delete: { show :false }
          },
          table: {
            operation: {
              //调用查看、编辑、删除接口时，需要传递的参数主键名称，可以有多个。默认为id
              primaryKey: "id",
              buttons: [
                {key: "view", show: true, label: "查看", theme: "text", click: ( row, index,_this) => {
                  _this.optViewClick(row, index);
                }},
                {key: "edit", show: true, label: "编辑", theme: "primary", click: (row, index,_this) => {
                  _this.optEditClick(row, index);
                }},
              ]
            },
            columns: [
              {title: '收件人名', key: 'consignee'},
              {title: '手机号', key: 'mobile'},
              {title: '邮编', key: 'zipCode'},
              {title: '手机号', key: 'mobile'},
              {title: '所属客户', key: 'customerNickname'},
              {title: '所属区域', key: 'areaFullName'},
              {title: '是否默认', key: 'defaultReceiver'},
            ]
          }
        }
      }
    },
    methods: {}
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
